

from collections import defaultdict;


user_dict = {};
users = ["name2","name2","name3","name1","name2"];

# for user in users:
#     if user not in user_dict:
#         user_dict[user] = 1;
#     else:
#         user_dict[user] +=1;


# for user in users:
#     user_dict.setdefault(user,0)
#     user_dict[user] += 1;


default_dict = defaultdict(int);
for user in users:
    default_dict[user] +=1;


print(default_dict.get("name2"));


def gen_default():
    return {"name":"","nums":0};

default_dict1 = defaultdict(gen_default);
print(default_dict1["1"]);
